import axios from "axios"
import Vue from 'vue'

// 由于开发环境需要给图片加http://localhost:3000.,生产环境不需要。所以在http.js 中做环境判断
//环境配置
if (process.env.NODE_ENV == "development") {
    // 开发环境
    Vue.prototype.$pre = "http://localhost:3000"
} else {
    // 生产环境
    Vue.prototype.$pre = ""
}




// 登录
export let reqLogin = (user) => {
    return axios({
        url: "/api/login",
        method: "post",
        data: user,
    })
};

// 注册
export let reqRegister = (user) => {
    return axios({
        url: "/api/register",
        method: "post",
        data: user,
    })
};

// 轮播图
export let reqBanner = () => {
    return axios({
        url: "/api/getbanner",
        method: "get",
        params: {},
    })
};

// home页分类数据
export let reqSort = () => {
    return axios({
        url: "/api/getcate",
        method: "get",
        params: {},
    })
};

// home页具体商品
export let reqGoods = () => {
    return axios({
        url: "/api/gethortgoods",
        method: "get",
        params: {},
    })
};

// list页信息
export let reqList = (list_msg) => {
    return axios({
        url: '/api/getgoodlist',
        method: 'get',
        params: list_msg
    })
};

// 搜索
export let reqSearch = (kw) => {
    return axios({
        url: '/api/search',
        method: 'get',
        params: kw
    })
}